/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2021-01-17
 * Time: 12:20
 */
#include "TestWidget.h"

TestWidget::TestWidget(QWidget *parent)
{
    this->resize(400, 300);
    InitUi();
    InitEvent();
}

void TestWidget::InitUi()
{
    //this->setWindowFlag();
    listWidget_ = new QListWidget();
    QMetaEnum m = QMetaEnum::fromType<Qt::WindowType>();
    for (int i = 0; i < m.keyCount(); ++i) {
        auto item = new QListWidgetItem();
        qDebug() << "i=" << i << ":" << m.key(i);
        item->setText(m.key(i));
        listWidget_->addItem(item);
    }
    listWidget_->show();
}

void TestWidget::InitEvent()
{
    connect(listWidget_, &QListWidget::currentRowChanged, [=](int currentRow) {
        Qt::WindowType type = static_cast<Qt::WindowType>(currentRow);
        this->setWindowFlag(type, true);
        this->clearMask();
        if(this->isHidden())
            this->show();
    });
}